<?php

namespace app\utils\ui\ele;

use app\utils\ui\native_element\Element;
use app\utils\ui\Script;
use app\utils\ui\vue\VueScript;

/**
 * 该东西输出ele所需的script内容，不放在节点数中，单独使用，vue3
 */
class EleScript extends VueScript implements Script {


    public function script()
    {
        $css =new Element('link',false,[
            'href'=>"https://unpkg.com/element-plus@2.3.5/dist/index.css",
            'rel'=>'stylesheet'
        ]);
        $before_html=$css->render().PHP_EOL;

        //vue
        $element = new Element('script',true,[
            'src'=>'https://unpkg.com/vue@3/dist/vue.global.js'
        ]);

        $before_html.=$element->render().PHP_EOL;

        //element ui
        $script = new Element('script',true,[
            'src'=>'https://unpkg.com/element-plus@2.3.5/dist/index.full.js'
        ]);
        $before_html.=$script->render().PHP_EOL;

        $script=new Element('script',true,
        [
            'src'=>'https://unpkg.com/@element-plus/icons-vue@2.1.0/dist/index.iife.min.js'
        ]);
        $before_html.=$script->render().PHP_EOL;

        //初始化VUE完成后执行，导入所有element的图标
        $hit = '
        for(var k in ElementPlusIconsVue){
            app.component(k,ElementPlusIconsVue[k])
        }
        '.PHP_EOL;


        $html =$this->app_script($before_html,'app.use(ElementPlus);'.PHP_EOL.$hit);
        return $html.PHP_EOL;
    }
}